//
//  LGSymptomViewCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/5/15.
//  症状Cell

#import "LGSymptomViewCell.h"

@interface LGSymptomViewCell()

/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UILabel *symptomLabel;
/**   */
@property (nonatomic , strong)UILabel *startLabel;
/**   */
@property (nonatomic , strong)UILabel *endLabel;
/**   */
@property (nonatomic , strong)UILabel *continueLabel;

@end

@implementation LGSymptomViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.symptomLabel.text = LGNSString(dataDic[@"symptom_name"]);
    self.startLabel.text = LGNSString(dataDic[@"start_date"]);
    self.endLabel.text = LGNSString(dataDic[@"end_date"]);
    self.continueLabel.text = [NSString stringWithFormat:@"%@天",dataDic[@"days"]];
}


-(void)createSubView{
    self.clipsToBounds = YES;
    self.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.baseView];
    [self.contentView addSubview:self.symptomLabel];
    [self.contentView addSubview:self.startLabel];
    [self.contentView addSubview:self.endLabel];
    [self.contentView addSubview:self.continueLabel];
    [self createLineView];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(-viewPix(10));
        make.left.equalTo(self.contentView).offset(viewPix(16));
        make.right.equalTo(self.contentView).offset(-viewPix(16));
        make.bottom.equalTo(self.contentView).offset(viewPix(10));
    }];
    [self.symptomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(19));
        make.top.equalTo(self.contentView).offset(viewPix(10));
        make.bottom.equalTo(self.contentView).offset(-viewPix(10));
        make.width.equalTo(@(viewPix(66)));
    }];
    [self.startLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(88));
        make.centerY.equalTo(self.contentView);
        make.width.equalTo(@(viewPix(110)));
    }];
    [self.endLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(198));
        make.centerY.equalTo(self.contentView);
        make.width.equalTo(@(viewPix(110)));
    }];
    [self.continueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(309));
        make.centerY.equalTo(self.contentView);
        make.width.equalTo(@(viewPix(52)));
    }];
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [[UIView alloc] initWithFrame:CGRectMake(viewPix(16), -viewPix(10), Screen_W-viewPix(32), viewPix(52))];
        [_baseView setShadoWithColor:@"#B2BDC7" offset:CGSizeMake(0, 2) opacity:0.1 radius:7];
        _baseView.backgroundColor = [UIColor whiteColor];
        _baseView.clipsToBounds = YES;
    }
    return _baseView;
}

-(UILabel *)symptomLabel{
    if(!_symptomLabel){
        _symptomLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:0];
        _symptomLabel.frame = CGRectMake(viewPix(3), 0, viewPix(66), viewPix(52));
    }
    return _symptomLabel;
}

-(UILabel *)startLabel{
    if(!_startLabel){
        _startLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
        _startLabel.frame = CGRectMake(viewPix(72), 0, viewPix(110), viewPix(52));
    }
    return _startLabel;
}

-(UILabel *)endLabel{
    if(!_endLabel){
        _endLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
        _endLabel.frame = CGRectMake(viewPix(182), 0, viewPix(110), viewPix(52));
    }
    return _endLabel;
}

-(UILabel *)continueLabel{
    if(!_continueLabel){
        _continueLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
        _continueLabel.frame = CGRectMake(viewPix(293), 0, viewPix(50), viewPix(52));
    }
    return _continueLabel;
}

-(void)createLineView{
    UIView *topLine = [[UIView alloc]initWithFrame:CGRectMake(0, viewPix(10), Screen_W-viewPix(32), 0.5)];
    topLine.backgroundColor = [UIColor colorWithString:@"#F2F2F2"];
    [self.contentView addSubview:topLine];
    [topLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(viewPix(16));
        make.right.equalTo(self.contentView).offset(-viewPix(16));
        make.height.equalTo(@(0.5));
    }];
    
    UIView *lineView1 = [[UIView alloc]initWithFrame:CGRectMake(viewPix(72), 0, 0.5, viewPix(50))];
    lineView1.backgroundColor = [UIColor colorWithString:@"#F2F2F2"];
    [self.contentView addSubview:lineView1];
    [lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(viewPix(88));
        make.width.equalTo(@(0.5));
    }];
    
    UIView *lineView2 = [[UIView alloc]initWithFrame:CGRectMake(viewPix(182), 0, 0.5, viewPix(50))];
    lineView2.backgroundColor = [UIColor colorWithString:@"#F2F2F2"];
    [self.contentView addSubview:lineView2];
    [lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.bottom.equalTo(lineView1);
        make.left.equalTo(self.contentView).offset(viewPix(198));
    }];
    
    UIView *lineView3 = [[UIView alloc]initWithFrame:CGRectMake(viewPix(293), 0, 0.5, viewPix(50))];
    lineView3.backgroundColor = [UIColor colorWithString:@"#F2F2F2"];
    [self.contentView addSubview:lineView3];
    [lineView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.bottom.equalTo(lineView1);
        make.left.equalTo(self.contentView).offset(viewPix(309));
    }];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
